use crate::errors::XError;
use std::str::FromStr;

/// 目前只支持riscv64
#[derive(Debug, Clone, Copy)]
pub(crate) enum Arch {
    Riscv64,
}

impl Arch {
    /// Return the name of Arch.
    #[inline(always)]
    pub const fn name(&self) -> &'static str {
        match self {
            Arch::Riscv64 => "riscv64",
        }
    }
}

impl FromStr for Arch {
    type Err = XError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "riscv64" => Ok(Self::Riscv64),
            _ => Err(XError::EnumParse {
                type_name: "Arch",
                value: s.to_string(),
            }),
        }
    }
}
